function fprimex = numderinterp1(x,dh,xgrid,ygrid,interp_type)
%finds the two-sided numerical derivative of a single-valued function y=f() at a point x
%Uses interp_type for interpolation between gridpoints

%Input: x: 1 x mm vector of points where the derivative is evaluated
%       dh: scalar of the of width of the numerical derivative
%       xgrid: 1 x nn vector of x values
%       ygrid: 1 x nn vector of y values
%       interp_type: 'linear', 'cubic'

%Output fprimex: 1 x mm vector of f'(x)

%values of f(x+dh) and f(x-dh)
fxpdh = finterp(x+dh);
fxmdh = finterp(x-dh);

fprimex = (fxpdh-fxmdh)/(2*dh);

 function y = finterp(x)
   y = interp1(xgrid,ygrid,x,interp_type);  
 end


end

